package ctgu.yao.cloud.controller;


import ctgu.yao.cloud.dto.ResultDTO;
import ctgu.yao.cloud.form.RuleForm;
import ctgu.yao.cloud.form.RuleForm2;
import ctgu.yao.cloud.mapper.ResumeMapper;
import ctgu.yao.cloud.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import ctgu.yao.cloud.po.Resume;
import org.springframework.web.bind.annotation.PathVariable;
import ctgu.yao.cloud.util.ResultDTOUtil;
import ctgu.yao.cloud.util.ResultDTOUtil;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Y
 * @since 2022-08-16
 */
@RestController
@RequestMapping("/resume")
public class ResumeController {
    @Autowired
    private ResumeService resumeService;
    @GetMapping("/login")
    public ResultDTO login(RuleForm ruleForm){
        ResultDTO resultDTO =this.resumeService.login(ruleForm);
        return resultDTO;
    }
    @GetMapping("/register")
    public ResultDTO register(RuleForm2 ruleForm){
        return this.resumeService.register(ruleForm);
    }
    //简历信息修改
    @GetMapping("/findById/{id}")
    public ResultDTO findByID(@PathVariable("id") Integer id){
        Resume resume = this.resumeService.getById(id);
        return ResultDTOUtil.success(resume);
    }
    @PutMapping("/update")
    public ResultDTO update(@RequestBody Resume resume){
        boolean update=this.resumeService.updateById(resume);
        if(!update) return ResultDTOUtil.fail();
        return ResultDTOUtil.success(null);
    }
}
